package com.heima.admin.controller.v1;

import com.heima.admin.service.AdminSensitiveService;
import com.heima.model.admin.dtos.SensitiveDto;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Psycho
 * @create 2022-05-02-11:10
 */
@RestController
@RequestMapping("/wemedia/api/v1/sensitive")
public class AdminSensitiveController {

    @Autowired
    private AdminSensitiveService adminSensitiveService;

    /**
     * 查询敏感词
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult listSensitives(@RequestBody SensitiveDto dto){
        return adminSensitiveService.listSensitives(dto);
    }

    /**
     * 删除某个敏感词
     * @param id
     * @return
     */
    @DeleteMapping("/del/{id}")
    public ResponseResult deleteOneSensitive(@PathVariable("id") Integer id){
        return adminSensitiveService.deleteOneSensitive(id);
    }

    /**
     * 修改某个敏感词
     * @param adSensitive
     * @return
     */
    @PostMapping("/update")
    public ResponseResult updateOneSensitive(@RequestBody AdSensitive adSensitive){
        return adminSensitiveService.updateOneSensitive(adSensitive);
    }


    /**
     *
     * @param adSensitive
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveOneSensitive(@RequestBody AdSensitive adSensitive){
        return adminSensitiveService.saveOneSensitive(adSensitive);
    }
}
